package com.x.erp.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.x.erp.model.InsuranceGoods;
import com.x.erp.rpc.InsuranceGoodsRpcService;
import com.x.framework.controller.BaseController;
import com.x.framework.controller.ResultCode;
import com.x.framework.controller.ResultModel;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 延保商品Controller
 *
 * @author pansong
 */
@RestController
@RequestMapping(value = "/insuranceGoods")
public class InsuranceGoodsController extends BaseController {

	@Reference
	private InsuranceGoodsRpcService insuranceGoodsRpcService; // 延保商品服务RpcService

	/**
	 * 获取延保商品列表
	 *
	 * @param insuranceGoods
	 * @return
	 */
	@RequestMapping(value = "/selectInsuranceGoodsList", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel selectGoodsList(InsuranceGoods insuranceGoods) {
		List<InsuranceGoods> list = insuranceGoodsRpcService.selectInsuranceGoodsList(insuranceGoods);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功", list);
	}

	/**
	 * 获取单个延保商品信息
	 *
	 * @param insuranceGoods
	 * @return
	 */
	@RequestMapping(value = "/selectInsuranceGoods", method = {RequestMethod.POST, RequestMethod.GET})
	public ResultModel selectInsuranceGoods(InsuranceGoods insuranceGoods) {
		InsuranceGoods temp = insuranceGoodsRpcService.selectInsuranceGoods(insuranceGoods);
		return new ResultModel(ResultCode.RESULT_SUCCESS, "查询成功", temp);
	}
}
